<form id="formEdit">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">编辑</h4>
            </div>
            <div class="modal-body">
            	<!-- 以下为要修改的的内容 -->
				<input type="hidden" name="id" data-th-value="${model.id}">
                <div class="form-group">
                	<label for="txt_name">课程名称</label>
                    <input type="text" name="name" data-th-value="${model.name}" class="form-control" id="name" placeholder="课程名称">
                </div>
                <div class="form-group">
                	<label for="txt_creditHour">课时数</label>
                    <input type="text" name="creditHour" data-th-value="${model.creditHour}" class="form-control" id="txt_creditHour" placeholder="课时数">
                </div>
                <div class="form-group">
                	<label for="txt_idx">排序</label>
                    <input type="text" name="idx" data-th-value="${model.idx}" class="form-control" id="txt_idx" placeholder="排序">
                </div>
                <!-- 以上为要修改的内容 -->
            </div>
            <div class="modal-footer">
                <button type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span>保存</button>
                <button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span>关闭</button>
            </div>
        </div>
    </div>
</form>
<script type="text/javascript" th:inline="javascript">
    $(function () {
 		var options= {
			message: '验证不通过',
			feedbackIcons: {
              valid: 'glyphicon glyphicon-ok',
              invalid: 'glyphicon glyphicon-remove',
              validating: 'glyphicon glyphicon-refresh'
          	},
          	fields:  {
				name: {
					validators: {
						notEmpty: {
							message: '课程名称不能为空'
						}
					}
				},
				creditHour:{
					validators:{
						regexp: {
                            regexp: /^[1-9][0-9]*$/,
                            message: '课时数必须为整数'
                        }
					}
				},
				idx: {
					validators: {
						notEmpty: {
							message: '排序不能为空'
						},
						numeric:{
							message: '只能输入数值'
						}
					}
				}
		}
 	};
        $('#formEdit').bootstrapValidator(options).on('success.form.bv', function(e) {
        	e.preventDefault();	//很重要没有它则会提交默认表单，不会做下面的ajax表单提交
            var fd = new FormData($("#formEdit")[0]);
            $.ajax({  
              url: "save",  
              type: "POST",  
              data: fd,  
              processData: false,  // 不处理数据  
              contentType: false,   // 不设置内容类型
              success:function(){
            	  $('#myModal').modal("hide");
              }
            });  
        });

    });
</script>